<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8"%>
<%@ include file="/common/taglibs.jsp"%>

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<script type="text/javascript" src="${ctx }/js/bootstrap/jquery.js"></script>
<script type="text/javascript" src="${ctx }/js/My97DatePicker/WdatePicker.js"></script>
<title>系统常量列表</title>
<script type="text/javascript">

$(function(){	
	var search = false;
	$('#demoForm').find('input:text').each(function(){
		if($.trim($(this).val())!=''){
			search = true;
		}
	});
	$('#demoForm').find('select').each(function(){
		if($(this).val()!=''){
			search = true;
		}
	});
	if(search){
		$(".project-searchbox").show();
		$(".project-searchbutton").html("<i class='icon-chevron-up'></i> 收起查询");
	}

});
function updateVal(id){
	$('#val'+id).hide();
	$('#edit'+id).show();
	$('#update'+id).hide();
	$('#save'+id).show();
}
function saveVal(id){
	var newVal = $('#edit'+id).find('input').val();
	var oldVal = $('#val'+id).html();
	if($.trim(newVal)!=oldVal){
		$.post('${ctx}/sysConstant/update',{id:id,value:newVal},function(data){
			if(data=='true'){
				art.dialog({content:"保存成功！",
					ok:function(){
						window.location.href="${ctx}/sysConstant/list";
					}
				});
			}else{
				art.dialog({content:"保存失败！"});
			}
		},'text');
	}else{
		$('#val'+id).show();
		$('#edit'+id).hide();
	}
	$('#update'+id).show();
	$('#save'+id).hide();
}
</script>
</head>
<body>
	<div class="breadcrumbs" id="breadcrumbs">
		<script type="text/javascript">
        try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
    </script>

		<ul class="breadcrumb">
			<li><i class="ace-icon fa fa-home home-icon"></i> <a
				href="${ctx }/home/home">首页</a></li>
			<li class="active">系统管理</li>
			<li class="active">系统常量管理</li>
		</ul>
		<!-- .breadcrumb -->
	</div>

	<div class="page-content">
		<div class="page-header">
			<h1>
				系统常量管理<small> <i class="ace-icon fa fa-double-angle-right"></i> 系统常量列表
				</small>
				<div style="float: right;">
					<button type="button"
						class="btn btn-primary btn-sm project-searchbutton">
						<i class="ace-icon fa fa-search"></i>展开查询
					</button>
				</div>
			</h1>
		</div>
		<!-- /.page-header -->

		<div class="row">
			<div class="col-xs-12 project-searchbox" style="display: none;">
				<div class="well col-xs-12">
					<form id="demoForm" class="form-horizontal" action="${ctx}/sysConstant/list" method="post">
						<input type="hidden" id="pageNo" name="pageNo" value="${page.pageNo }" />
						<div class="col-xs-12 col-md-6 col-lg-4">
							<div class="form-group">
								<label for="name" class="col-sm-4 control-label"><strong>常量名称</strong></label>
								<div class="col-sm-8">
									<input type="text" id="name" name="name" value="${sysConstant.name}" class="form-control">
								</div>
							</div>
						</div>
						<div class="col-xs-12 col-md-6 col-lg-4" style="float: right;">
							<div class="col-sm-8 col-sm-offset-4 project-nopadding"
								style="text-align: right;">
								<button type="button" class="btn btn-primary btn-sm"
									onclick="doSubmit('demoForm')">
									<i class="ace-icon fa fa-search"></i> 查询
								</button>
								<button type="button" class="btn btn-default btn-sm"
									onclick="doFormReset('demoForm')">
									<i class="ace-icon fa fa-undo"></i>重置
								</button>
							</div>
						</div>
					</form>
				</div>
			</div>
			<div class="col-xs-12">
				<!-- <div class="space-10"></div> -->
				<div class="table-responsive">
				 <display:table class="project-default" name="page.result" style="width:100%;border:0;" id="sc">
            		<display:column property="name" title="常量名称" style="width:30%"/>
            		<display:column title="常量值" style="width:30%">
            			<span id="val${sc.id }">${sc.value }</span>
            			<span id="edit${sc.id }" style="display: none"><input style="text-align: center" value="${sc.value }"/></span>
            		</display:column>
            		<display:column title="更新时间">
            			<fmt:formatDate value="${sc.updateTime }" pattern="yyyy-MM-dd HH:mm"/>
            		</display:column>
            		<display:column title="操作">
            			<shiro:hasPermission name="sysConstant:update">
							<a id="update${sc.id }" href="javascript:void(0);" onclick="updateVal(${sc.id})" title="">修改</a>
							<a id="save${sc.id }" href="javascript:void(0);" style="display:none" onclick="saveVal(${sc.id})" title="">保存</a>
						</shiro:hasPermission>
            		</display:column>
				 </display:table>
				 </div>
			</div>
		</div>
		<div class="row">
			<div class="col-xs-12">
				<div class="space-10"></div>
				<div class="project-pagebox">
					<div>
						<p:writerPage pageNo="${page.pageNo }" pageSize="${page.pageSize }" totalCount="${page.totalCount }" formId="demoForm" />
					</div>
				</div>
			</div>
		</div>
	</div>
</body>
</html>